﻿@model BbsListModel
@{
    ResLink.AddCss("~/res/css/bbs/list.css");
}

<h1>@Model.게시판.제목</h1>
<hr />

<div class="controls pull-right">
    @if (BL사용자.IsAdminOrStaff()) {
        <a href="@Url.BbsAdminEdit(Model.게시판.ID)" class="btn btn-small">관리</a>
    }
    <a href="@Url.BbsNew(Model.게시판.ID)" class="btn btn-small btn-primary">글쓰기</a>
</div>
<div class="form-inline">
    <span>분류:</span>
    @Html.DropDownListFor(m => m.pagination.category, Model.게시글분류목록, new { onchange = "게시글분류변경(this.value)" })
    @Html.DropDownListFor(m => m.pagination.srchType, BL게시판.검색유형목록)
    @Html.TextBoxFor(m => Model.pagination.srchText)
    <a onclick="게시판검색()" class="btn btn-small">검색</a>
</div>

<table class="table table-condensed table-bordered">
    <thead>
        <tr>
            <th>번호</th>
            <th>제목</th>
            <th>작성자</th>
            <th>작성일</th>
        </tr>
    </thead>
    <tbody>
        @foreach(var 글 in Model.게시글목록) {            
            <tr onclick="document.location='@Url.BbsArticle(글.ID)';">
                <td>@글.번호</td>
                <td><span>[@글.분류]</span> @글.제목</td>
                <td>@글.작성자</td>
                <td>@글.수정일.ToYMD()</td>
            </tr>
        }
    </tbody>
</table>

<div class="controls pull-right form-inline">
    화면크기: 
    @Html.DropDownListFor(m => m.pagination.size, new SelectList(Consts.페이지크기목록), new { onchange = "페이지크기변경(this.value)" })
</div>

@Html.Partial("_Pagination", Model.pagination)

<script type="text/javascript">
    function 게시글분류변경(categoryId) {
        var url = "@Html.Raw(Url.BbsListCategory(Model.게시판.ID, 9999))";
        location.href = url.replace("9999", categoryId);
    }
    function 페이지크기변경(size) {
        var url = "@Html.Raw(Url.BbsListResize(Model.게시판.ID, 9999))";
        location.href = url.replace("9999", size);
    }
    function 게시판검색() {
        var url = '@Html.Raw(Url.BbsListSearch(Model.게시판.ID, 9991, "9992"))';
        var 검색유형 = $('select[name$=srchType]').val();
        var 검색어 = encodeURIComponent($('input[name$=srchText]').val().trim());
        location.href = url.replace("9991", 검색유형).replace("9992", 검색어);
    }
</script>

